# Q: write a function to rotate the elements of an array. The function takes
# two arguments: the array to be rotated and the number of elements to rotate,
# where a positive count rotates to the left and a negative count rotates to
# the right. For instance, given the array [1 2 3 4 5 6], a rotation of 2 to
# the left gives [3 4 5 6 1 2], and a further rotation of 2 to the right
# restores the original array. You should be sure to handle the edge cases
# properly. If the count is zero or the length of the array, the array should
# remain unchanged. If the count is greater than the length of the array, you
# should still do the right thing; for instance, a rotation of 8 on the array
# given above gives [3 4 5 6 1 2], the same as a rotation of 2.
#
# A: What really matter is the count mod by the length of the array. The result
# is the number indicating indicating the index at which we need to split the
# array. Move all the elements starting from index to the front of the array,
# while move all the elements starting at the beginning upto but not include the
# index to the back.

def rotate_array(array, count):
   length = len(array)
   actualCount = count % length
   array[:] = array[actualCount:] + array[0:actualCount]
   
for n in range(12):
   array = [1,2,3,4,5,6]
   rotate_array(array, n)
   print('n =', n, ':', array)
